package com.xbs.controller.enterprise;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xbs.controller.base.BaseServlet;
import com.xbs.entity.EnterpriseOrderEntity;
import com.xbs.entity.EnterpriseOrderQueryEntity;
import com.xbs.service.enterprise.EnterpriseSelfOrderService;
import com.xbs.utils.PageUtilEntity;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.JsonConfig;
import net.sf.json.processors.JsonBeanProcessor;
import net.sf.json.util.CycleDetectionStrategy;
@WebServlet("/enterprise/ordermanager/mulquery")
public class SelfOrderQuery extends BaseServlet{
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		String startTime=req.getParameter("startTime");
		String endTime=req.getParameter("endTime");
		String state=req.getParameter("state");
		Integer currPage=Integer.parseInt(req.getParameter("currpage"));
		Integer pageSize=Integer.parseInt(req.getParameter("pageSize"));
		EnterpriseSelfOrderService service=new EnterpriseSelfOrderService();
		
		EnterpriseOrderQueryEntity e=new EnterpriseOrderQueryEntity();
		e.setAccount("fykj");
		e.setEndTime(endTime);
		e.setStartTime(startTime);
		e.setState(state);
		e.setRentState(0);
		PageUtilEntity pe=service.getSelfOrderMulconditionPage(e, currPage, pageSize);
		/*List<EnterpriseOrderEntity> orders=service.getSelfOrderMulcondition(e);*/
		JsonConfig jsonConfig = new JsonConfig();   
		jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);   
		jsonConfig.registerJsonBeanProcessor(java.sql.Date.class, new DateJsonValueProcessor());  
		jsonConfig.setExcludes(new String[]{"handler","hibernateLazyInitializer"});    
		/*JSONArray.fromObject(list,jsonConfig);  */
		JSONArray jsonArray = JSONArray.fromObject(pe.getIst(),jsonConfig);
		JSONObject obj =JSONObject.fromObject(pe,jsonConfig); 
		resp.getWriter().print(obj.toString());
	}
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
}
//重载类型

